package com.coursehub.course.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 班级教师关联实体类
 */
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "classes_teacher")
public class ClassesTeacher {
    
    @EmbeddedId
    private ClassesTeacherId id;
    
    @MapsId("classesId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "classes_id", nullable = false)
    private Classes classes;
    
    // 在微服务架构中，我们不维护User实体的引用，只存储userId
    // 用户详细信息通过用户管理服务获取
    
    public ClassesTeacher(ClassesTeacherId id, Classes classes) {
        this.id = id;
        this.classes = classes;
    }
    
    public String getUserId() {
        return id != null ? id.getUserId() : null;
    }
}